// -----------------------------------------------------------------------
//  <copyright file="GetUserPageQuery.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/10 8:37:50</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Domain.Entities;


namespace DaprPlus.Identity.Application.Identity.Users.Queries;

[AuthConfig(typeof(User), ResourceAccessType.RoleLimit, "GetPage")]
public class GetUserPageQuery : PageQuery<PageResult<UserOutDto>>
{ }

public class GetUserPageQueryHandler(IQueryRepository<User> queryRepository)
    : IRequestHandler<GetUserPageQuery, PageResult<UserOutDto>>
{
    public async Task<PageResult<UserOutDto>> Handle(GetUserPageQuery request,
        CancellationToken cancellationToken)
    {
        var spec = new PageQuerySpecification<User>(request.PageCondition, request.FilterGroup);
        var page = await queryRepository.GetPageAsync<UserOutDto>(spec, cancellationToken);
        return page;
    }
}

